home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1380 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  994 b 

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is wrong in this code?
  5. Date: 13 Jan 1996 00:08:18 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4d7eo2$hcl@umbc9.umbc.edu>
  8. References: <DL2z7o.2K5@scisun.sci.ccny.cuny.edu>
  9. NNTP-Posting-Host: f-umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. Sergio Rojas <sergio@sci.ccny.cuny.edu> wrote:
  13. |>   I am traying to be literate in C and here is a
  14. |> problem wich I have been unable to detect:
  15. |> 
  16. |> #include <stdio.h>
  17. |> #include <math.h>
  18. |>
  19. |> main()
  20. |> {
  21. |> double x;
  22. |> 
  23. |> printf("\n Enter a number \n");
  24. |> 
  25. |> scanf("%f", &x);
  26.  
  27. <rest deleted>
  28.  
  29. This is in the FAQ...
  30.  
  31. 12.13:    Why doesn't this code:
  32.  
  33.         double d;
  34.         scanf("%f", &d);
  35.  
  36.     work?
  37.  
  38. A:    Unlike printf(), scanf() uses %lf for values of type double, and
  39.     %f for float.  See also question 12.9.
  40. -- 
  41. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  42.  
  43. Jonas J. Schlein  (schlein@gl.umbc.edu)
  44.